import mysql.connector
import sys
#ys.path.append(r'C:\Users\dev\Desktop\chenchen-fast-start\chenchen-fast-start\script\python\venv\Include\pyttsx3')
#import pyttsx3_util

mydb = mysql.connector.connect(
    host="10.43.86.14",  # 数据库主机地址
    user="environment_sky_rw",  # 数据库用户名
    port=3306,
    database="environment_sky_db",  # 数据库名称 没有的话插入操作报错
    passwd="Dop9IxnJB89v!",  # 数据库密码
    auth_plugin="mysql_native_password"
    # host="192.168.47.102",  # 数据库主机地址
    # port=3306,
    # user="ccmadmin",  # 数据库用户名
    # database="mh_xiyou",#数据库名称 没有的话插入操作报错
    # passwd="211314wccA@"  # 数据库密码

)

select_sql="SELECT word,chinese FROM iridescent_english_word LIMIT {},{}"

table_name = 'item_user_config_info_sky'
sql = "SHOW COLUMNS FROM " + table_name

mycursor = mydb.cursor()
mycursor.execute(sql)
results = mycursor.fetchall()

#INSERT INTO `base_city_cluster_info`
#()
#SELECT

#FROM vm_checkpoint_device_info_t_tmp


insert_sql="INSERT INTO "+table_name+" ("
ii=0
for row in results:
    if ii==0:
        insert_sql = insert_sql + row[0]
    else:
        insert_sql = insert_sql+ ", " + row[0]
    #print(ii)
    ii+=1

insert_sql =insert_sql + " )"
insert_sql=insert_sql+ " SELECT "
ii2=0
for row in results:
    if ii2==0:
        insert_sql = insert_sql + row[0]
    else:
        insert_sql = insert_sql+ ", " + row[0]
    #print(ii)
    ii2+=1
insert_sql=insert_sql+ " FROM "+ table_name +"_tmp"

print(insert_sql)

# tmp_sql=select_sql.format(i*100,"100")
#     print(tmp_sql)
#     tmp_write_str=""
#     tmp_count=0
#     for row in results:
#         tmp_count=tmp_count+1
#         tmp_write_str=tmp_write_str+", 第 "+tmp_count.__str__()+"个单词";
#         tmp_write_str=tmp_write_str+row[0];
#         tmp_write_str=tmp_write_str+",";
#         for tmp_char in row[0]:
#             #print(tmp_char)
#             tmp_write_str = tmp_write_str + tmp_char;
#             tmp_write_str = tmp_write_str +" ";
#         tmp_write_str=tmp_write_str+" ,,";
#         tmp_write_str=tmp_write_str+row[0];
#         tmp_write_str=tmp_write_str+" ,,";
#         tmp_write_str=tmp_write_str+row[1];
    #print(tmp_write_str)
    #ttx.write_to_file(tmp_write_str,
     #                 "C:\\Users\\dev\\Desktop\\chenchen-fast-start\\chenchen-fast-start\\script\\python\\venv\\Include\\pyttsx3\\tmp\\unit" + (
    #                              i + 1).__str__() + ".mp3")



#ttx.sayText('''''')
